/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.cx1.dao.impl;

import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;
import java.io.IOException;
import java.io.Reader;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author tina
 */
public class IbatisConnectionFactory {
   
    private static SqlMapClient sqlMapClient;

    public static SqlMapClient getSqlMapClient() {
        
        if (sqlMapClient == null) {
            Reader rd = null;
        
            try {
                rd = Resources.getResourceAsReader("org/cx1/config/SqlMapConfig.xml");
            } catch (IOException ex) {
                Logger.getLogger(IbatisConnectionFactory.class.getName()).log(Level.SEVERE, null, ex);
            }
        
            if (sqlMapClient == null) {
                sqlMapClient = SqlMapClientBuilder.buildSqlMapClient(rd);
            }
            
        }
        
        return sqlMapClient;
    }
}
